////////////////////////////////////////////////////////////////////////////////
//
//  Source code for the paper
//
//  "Fast Ray--Tetrahedron Intersection"
//
//  (c) Nikos Platis, Theoharis Theoharis 2003
//
//  Department of Informatics and Telecommunications,
//  University of Athens, Greece
//  {nplatis|theotheo}@di.uoa.gr
//
////////////////////////////////////////////////////////////////////////////////

// http://realtimecollisiondetection.net/files/PlatisRayTetra/

#ifndef _Pluecker_hpp_
#define _Pluecker_hpp_

extern "C" {
#include "../env/vector.h"
}

// Pluecker ////////////////////////////////////////////////////////////////////

class Pluecker
{
private:
    vec3_t d;   // direction
    vec3_t c;   // cross

public:
    Pluecker() { };
    
    // Pluecker coordinates of a ray specified by points orig and dest.
    Pluecker(const vec3_t orig, const vec3_t dest);

    // Pluecker coordinates of a ray specified by point orig and
    // direction dir. The bool parameter serves only to discriminate this
    // from the previous constructor
    Pluecker(const vec3_t orig, const vec3_t dir, bool haveDir);

    // Permuted inner product operator
    friend double operator*(const Pluecker& pl1, const Pluecker& pl2);
};


inline double operator*(const Pluecker& pl1, const Pluecker& pl2)
{
	return (DotProduct(pl1.d, pl2.c) * DotProduct(pl2.d, pl1.c));
}


#endif   // _Pluecker_hpp_
